<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>博彩</title>
</head>
<body>
<script>
		var url = "<%=request.getContextPath()%>/login/loginWindow.do";
		//alert(url);
		window.location.href = url;

		//this goes up to  170!//7.25 * 10^306 = 170!
		var answer ;
		var displaynum;
		var number ; 

		function calculate(number) {
		//7.25 * 10^306  170
		var dummy;
		var strAnswer;

			answer = number;
			displaynum = number;
		if (number < 0) answer = "undefined, number must be an integer >= 0";
			
		while (number >1) {
		   answer = answer* (number-1);
			number--;//dummy = answer;
			}
		return answer;}

		function factorial(form) {
		calculate(parseFloat(form.input.value));
		strAnswer = displaynum + "! = " + answer;
		form.displayAnswer.value = strAnswer;
		}
		 
		function combination(form)   {
		var r2num = parseFloat(form.nCombo.value) - parseFloat(form.rCombo.value);
		var n1 = calculate(parseFloat(form.nCombo.value));
		var r1 = calculate(parseFloat(form.rCombo.value));
		var r2 = calculate(r2num);
		if (r1 == 0) {r1 = eval(1);}
		if (r2 == 0) {r2 = eval(1);}
		 
		cboAnswer = Math.round(n1/(r1*r2));
		strAnswer = "C("+ form.nCombo.value + "," + form.rCombo.value + ") = " + cboAnswer;
		form.displayAnswer.value = strAnswer;
		}

		function permutation(form)   {
		var r2num = parseFloat(form.nCombo.value) - parseFloat(form.rCombo.value);
		var n1 = calculate(parseFloat(form.nCombo.value));
		var r1 = calculate(parseFloat(form.rCombo.value));
		var r2 = calculate(r2num);
		if (r1 == 0) {r1 = eval(1);}
		if (r2 == 0) {r2 = eval(1);}
		 
		cboAnswer = Math.round(n1/r2);
		strAnswer = "P("+ form.nCombo.value + "," + form.rCombo.value + ") = " + cboAnswer;
		form.displayAnswer.value = strAnswer;
		}

		
</script>
</body>
</html>